#! /usr/bin/env python

"""
Commands may aggregate other commands

Try for example
$ waf configure
$ waf test
"""

def options(ctx):
	ctx.load('compiler_c')

def configure(ctx):
	ctx.load('compiler_c')

def setup(ctx):
	n = ctx.path.make_node('main.c')
	n.write('#include "foo.h"\nint main() {return 0;}\n')

	global v
	m = ctx.path.make_node('foo.h')
	m.write('int k = %d;\n' % v)
	v += 1

def build(ctx):
	ctx.program(source='main.c', target='app')

def test(ctx):
	global v
	v = 12

	from waflib import Options
	lst = ['configure', 'setup', 'build', 'setup', 'build']
	Options.commands = lst + Options.commands

